package com.sunday.player.util;

import android.content.Context;
import android.content.SharedPreferences;

public class SundaySharedPreferences {
    private SharedPreferences sharedPreferences;
    public static String SharedID = "SundaySharedPreferences";
    public static final String firstMp3listLoad = "firstMp3listLoad";
    private Context mContext;
    public SundaySharedPreferences(Context con) {
	sharedPreferences = con.getSharedPreferences(SharedID, 0);
	mContext = con;
	
    }

	public String getStringSetting(String key, String default1) {
		SharedPreferences s = mContext.getSharedPreferences(SharedID, 0);
		String ret = s.getString(key, default1);
		if(ret == null){
			return default1;	
		}else{
			return ret;	
		}
		
	}
	public boolean getBooleanSetting(String key) {
		SharedPreferences s = mContext.getSharedPreferences(SharedID, 0);
		boolean ret = s.getBoolean(key, false);
		return ret;
	}
	public boolean getBooleanSetting(String key , boolean isboolean ) {
		SharedPreferences s = mContext.getSharedPreferences(SharedID, 0);
		boolean ret = s.getBoolean(key, isboolean);
		return ret;
	}
	public int getIntSetting(String key , int defulta) {
		SharedPreferences s = mContext.getSharedPreferences(SharedID, 0);
		int ret = s.getInt(key, defulta);
		return ret;
	}
	
	public void setSetting(final String key, final String value) {
	    SharedPreferences settings = mContext.getSharedPreferences(SharedID, 0);
		SharedPreferences.Editor editor = settings.edit();
		editor.putString(key, value);
		editor.commit();

        }
        public void setSetting(final String key, final boolean value) {

    		SharedPreferences settings = mContext.getSharedPreferences(SharedID, 0);
    		SharedPreferences.Editor editor = settings.edit();
    		editor.putBoolean(key, value);
    		editor.commit();
        	
        }
        public void setSetting(final String key, final int value) {
      
		SharedPreferences settings = mContext.getSharedPreferences(SharedID, 0);
		SharedPreferences.Editor editor = settings.edit();
		editor.putInt(key, value);
		editor.commit();
        	
        }

    
    /**
     * 최초 구동하는 mp3
     * @return
     */
    public boolean getFirstMp3listLoad() {
	return !getBooleanSetting(firstMp3listLoad);
    }
    
    
}
